/*
 * Cherry programming language
 * Copyright (C) 2013 Christoph Mueller
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <crystal/standard.h>
#include <stdlib.h>
#include <stdint.h>

struct CyArray;

struct CyFile {
  const char* filename;
  const byte_t* begin;  
};


struct CyContext {
  struct CyFile* file;
  
  byte_t* src;
  struct CryArray* buffer;
};


struct CyContext*   cy_context_new(const byte_t* source, const char* filename);
struct CyContext*   cy_context_repl_new(const byte_t* source);
void                cy_context_free(struct CyContext* context);

void                cy_error(struct CyContext* context, const char* format, ...);

enum CyTOK {
  TOK_EOF,
  TOK_ROUNDLEFTBRACE,
  TOK_ROUNDRIGHTBRACE,
  TOK_SQUARELEFTBRACE,
  TOK_SQUARERIGHTBRACE,
  TOK_COMMENT,
  TOK_DOT,
  TOK_STRING,
  TOK_CHAR,
  TOK_HEX,
  TOK_DEC,
  TOK_OCT,
  TOK_BIN,
  TOK_FLOAT,
  TOK_DEFINE,
  TOK_IDENTIFIER
};


const byte_t*       cy_tok_to_string(enum CyTOK token);

enum CyTOK          cy_lex(struct CyContext* context);
byte_t*             cy_token_string(struct CyContext* context);
size_t              cy_token_length(struct CyContext* context);

